** Open a connection to another host using telnet or tn3270
*/
void
do_tel_3270(ZeGopher)
GopherStruct *ZeGopher;
{
char *Dialogmess[20];
char sMessage1[128];
char sMessage2[128];
char sTelCmd[128];
/* retrieve the gopher information for the telnet command*/
clear();
Dialogmess[0] = "Warning!!!!!, you are about to leave the Internet";
Dialogmess[1] = "Gopher program and connect to another host. If";
Dialogmess[2] = "you get stuck press the control key and the ] key,";
Dialogmess[3] = "and then type quit";
Dialogmess[4] = "";
if (GSgetPort(ZeGopher) != 0)
sprintf(sMessage1,"Connecting to %s, port %d using %s.", GSgetHost(ZeGopher),GSgetPort(ZeGopher), (GSgetType(ZeGopher) == A_TN3270) ? "tn3270" : "telnet");
else
sprintf(sMessage1, "Connecting to %s using %s.", GSgetHost(ZeGopher),(GSgetType(ZeGopher) == A_TN3270) ? "tn3270" : "telnet");
Dialogmess[5] = sMessage1;
if (*GSgetPath(ZeGopher) != '\0')
sprintf(sMessage2,"Use the account name \"%s\" to log in",
GSgetPath(ZeGopher));
else
sMessage2[0] = '\0';
Dialogmess[6] = "";
Dialogmess[7] = sMessage2;
Dialogmess[8] = NULL;
if (CURDialog(CursesScreen, GSgetTitle(ZeGopher), Dialogmess) <0)
return;
CURexit(CursesScreen);
if (GSgetType(ZeGopher) == 'T') {
/**** A TN3270 connection ****/
sprintf(sTelCmd, "%s %s", STRget(TN3270Command),
GSgetHost(ZeGopher));
} else
if (GSgetPort(ZeGopher) != 0 && GSgetPort(ZeGopher) != 23)
#if defined(VMS) && defined(MULTINET)
sprintf(sTelCmd, "%s %s /PORT=%d",
#else
sprintf(sTelCmd, "%s %s %d",
#endif
STRget(TelnetCommand), GSgetHost(ZeGopher),
GSgetPort(ZeGopher));
else
sprintf(sTelCmd, "%s %s", STRget(TelnetCommand),
GSgetHost(ZeGopher));
CURexit(CursesScreen);
system(sTelCmd);
CURenter(CursesScreen);
return;
}
/*
** do_index gets keywords from the user to search for. It returns
** it to the calling process. This storage is volotile. Callers should
** make a copy if they want to call do_index multiple times.
*/
char* do_index(ZeGopher)
GopherStruct *ZeGopher;
{
static char *inputline = NULL;
static char *prompt[2];
static char *response[2];
if (inputline == NULL) {
inputline = (char *) malloc(sizeof(char)*256);
if (inputline == NULL)
perror("Out of memory"), exit(-1);
*inputline = '\0';
}
prompt[0] = "Words to search for";
prompt[1] = NULL;
response[0] = inputline;
response[1] = NULL;
if (CURRequest(CursesScreen, GSgetTitle(ZeGopher),prompt, response) == -1 )
return(NULL);
if (*inputline == '\0')
return(NULL);
else
return(inputline);
}
/*
* this procedure just retrieves binary data from the socket and
* pumps it into a "play" process.
*/
#define BUFSIZE 1400 /* A pretty good value for ethernet */
#ifndef VMS
void
suck_sound(sockfd)
int sockfd;
{
FILE *Play;
int j;
char buf[BUFSIZE];
if (*STRget(PlayCommand) == '\0') {
/*** Hey! no play command, bummer ***/
CursesErrorMsg("Sorry, this machine doesn't support sounds");
return;
}
Play = popen(STRget(PlayCommand), "w");
while(1) {
j = read(sockfd, buf, BUFSIZE);
if (j == 0)
break;
fwrite(buf, 1, j, Play);
}
}
#endif
/*
* fork off a sound process to siphon the data across the net.
* So the user can listen to tunage while browsing the directories.
*/
void
do_sound(ZeGopher)
GopherStruct *ZeGopher;
{
#ifdef VMS
CursesErrorMsg("Sorry, this machine doesn't support sounds");